﻿package br.com.harmonia.Flash 
{
	
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.ui.Keyboard;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	
	public class Nave extends MovieClip
	{
		private var stageRef:Stage;
		
		public function Nave(stageRef:Stage) 
		{
			trace("222");
			this.stageRef = stageRef;
			stageRef.addEventListener(Event.ENTER_FRAME, update, false, 0, true);
			

		}
		
		public function update(e:Event) : void
		{
			trace("333");
			//addEventListener(KeyboardEvent.KEY_DOWN, handleKeyboardDown, false, 0, true);
			//stageRef.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyboardDown, false, 0, true);
		
		}
		
		public function teste(e:KeyboardEvent) : void
		{
			trace("666");
			if (e.keyCode==Keyboard.LEFT) 
				x -= 2;
			else if (e.keyCode==Keyboard.RIGHT)
				x += 2;
		}
		
		public function handleKeyboardDown(e:KeyboardEvent) : void
		{
			trace("444");
			if (e.keyCode==Keyboard.LEFT) 
				x -= 2;
			else if (e.keyCode==Keyboard.RIGHT)
				x += 2;
			
			if (e.keyCode==Keyboard.UP)
				y -= 2;
			else if (e.keyCode==Keyboard.DOWN)
				y += 2;
		}
		
	}
	
}